﻿using System;
using System.ServiceModel;
using QuailDashboard.View.QuailTestRunnerServiceReference;

namespace QuailDashboard.View.Helpers
{
    /// <summary>
    /// Wraps construction of the QuailTestRunnerClient object
    /// </summary>
    public static class QuailTestRunnerFactory
    {
        /// <summary>
        /// Creates a new instance of the QuailTestRunnerClient
        /// </summary>
        /// <returns>A new QuailTestRunnerClient</returns>
        public static QuailTestRunnerClient CreateClient()
        {
            var binding = new BasicHttpBinding(BasicHttpSecurityMode.None)
            {
                // ReaderQuotas = { MaxArrayLength = 20000000 },
                SendTimeout = new TimeSpan(0, 10, 0),
                ReceiveTimeout = new TimeSpan(0, 10, 0),
                MaxReceivedMessageSize = 2147483647,
                MaxBufferSize = 2147483647
            };
            var endpoint = new EndpointAddress(App.CurrentApp.TestRunnerServiceEndpointAddress);

            var result = new QuailTestRunnerClient(binding, endpoint);

            return result;
        }
    }
}
